﻿@namespace AntSK.Pages.ChatPage
@using AntSK.Domain.Repositories
@using AntSK.Models
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using AntSK.Pages.ChatPage.Components
@page "/Chat"
@page "/Chat/{AppId}"
@using AntSK.Services.Auth
@inherits AuthComponentBase

<GridRow Gutter="(16, 16)">
    <GridCol Span="14">
        <Card Style="height:75vh;overflow: auto;">
            <TitleTemplate>
                <Icon Type="setting" /> 选择应用
                <Select DataSource="@_list"
                        @bind-Value="@AppId"
                        DefaultValue="@("lucy")"
                        ValueProperty="c=>c.Id"
                        LabelProperty="c=>c.Name"
                        Style="width:200px">
                </Select>
                <a href="@( NavigationManager.BaseUri + "openchat/" + AppId)" target="_blank">分享使用</a>
            </TitleTemplate>
            <Body>
                @if (!string.IsNullOrEmpty(AppId))
                {
                    <Watermark Content="AntSK">
                        <ChatView AppId="@AppId" ShowTitle=false OnRelevantSources="OnRelevantSources"></ChatView>
                    </Watermark>
                }
            </Body>
        </Card>
    </GridCol>
    <GridCol Span="10">
        <Card Style="height: 75vh;overflow: auto;">
            <TitleTemplate>
                <Icon Type="search" /> 调试结果
            </TitleTemplate>
            <Extra>

            </Extra>
            <Body>
                <AntList Bordered DataSource="@_relevantSources" Style="padding:10px;">
                    <ChildContent Context="item">
                        <span> <b>@item.SourceName </b>  </span>
                        <br />
                        <span>相似度：<Text Mark> @item.Relevance</Text></span>
                        @if (@item.RerankScore != 0)
                        {
                            <br />
                            <span> Rerank相关性：<Text Mark> @item.RerankScore</Text></span>
                        }
                        <Body>
                            @((MarkupString)(@item.Text))
                        </Body>
                    </ChildContent>
                </AntList>
            </Body>
        </Card>
    </GridCol>
</GridRow>

<style>
    #chat {
        height: calc(75vh - 120px);
        display: flex;
        flex-direction: column;
        overflow-x: hidden;
        overflow-y: auto;
        margin: 0;
    }

    body {
        margin: 0;
        justify-content: center;
        align-items: flex-start;
        height: 100vh;
        overflow-y: hidden;
    }
</style>
@code {

}
